package org.Boxing;

public class TestBoxing {
    public static void testBoxEquals() {
        Integer x = 127;
        Integer y = 127;
        Integer m = 99999;
        Integer n = 99999;

        System.out.println("x == y: " + (x == y)); // true
        System.out.println("m == n: " + (m == n)); // false
        System.out.println("x.equals(y): " + x.equals(y)); // true
        System.out.println("m.equals(n): " + m.equals(n)); // true


        // 向上转型为Number:
        Number num = Integer.valueOf(999);
        // 获取byte, int, long, float, double:
        byte b = num.byteValue();
        int number = num.intValue();
        long ln = num.longValue();
        float f = num.floatValue();
        double d = num.doubleValue();

        System.out.printf("999 byte %s int %d long %d float %.1f double %.1f\n", Integer.toBinaryString(Byte.toUnsignedInt(b)), number, ln, f, d);
    }

}
